package com.zqxq.lottery.entity.o2o.sys;

import com.zqxq.common.utils.DispatcherUtils;
import com.zqxq.lottery.entity.po.sys.LotteryHnumPO;
import com.zqxq.lottery.entity.po.sys.LotteryKindPO;
import com.zqxq.lottery.entity.vo.sys.LotteryKindVO;

import java.util.ArrayList;
import java.util.List;

/**
 * @Description ：
 * @Author ： 解风
 * @Date ： 2018/03/14 16:13
 */
public class LotteryKindO2O {

    public static LotteryKindVO toVO(LotteryKindPO po) {
        if (po == null) {
            return null;
        }
        LotteryKindVO lotteryKindVO = new LotteryKindVO();
        lotteryKindVO.setId(DispatcherUtils.parseString(po.getId()));
        lotteryKindVO.setName(po.getName());
        lotteryKindVO.setImgUrl(po.getImg_url());
        lotteryKindVO.setH5Url(po.getH5_url());
        lotteryKindVO.setSort(DispatcherUtils.parseString(po.getSort()));
        lotteryKindVO.setStatus(DispatcherUtils.parseString(po.getStatus()));
        lotteryKindVO.setSaleStatus(DispatcherUtils.parseString(po.getSale_status()));
        lotteryKindVO.setTags(po.getTags());
        lotteryKindVO.setSign(po.getSign());
        lotteryKindVO.setHot(DispatcherUtils.parseString(po.getHot()));
        lotteryKindVO.setCreateTime(DispatcherUtils.parseDateTimeStr(po.getCreate_time()));
        lotteryKindVO.setUpdateTime(DispatcherUtils.parseDateTimeStr(po.getUpdate_time()));
        return lotteryKindVO;
    }

    public static LotteryKindPO toPO(LotteryKindVO vo) {
        if (vo == null) {
            return null;
        }
        LotteryKindPO lotteryKindPO = new LotteryKindPO();
        lotteryKindPO.setId(DispatcherUtils.parseLong(vo.getId()));
        lotteryKindPO.setName(vo.getName());
        lotteryKindPO.setImg_url(vo.getImgUrl());
        lotteryKindPO.setH5_url(vo.getH5Url());
        lotteryKindPO.setSort(DispatcherUtils.parseInteger(vo.getSort()));
        lotteryKindPO.setStatus(DispatcherUtils.parseInteger(vo.getStatus()));
        lotteryKindPO.setSale_status(DispatcherUtils.parseInteger(vo.getSaleStatus()));
        lotteryKindPO.setTags(vo.getTags());
        lotteryKindPO.setSign(vo.getSign());
        lotteryKindPO.setHot(DispatcherUtils.parseInteger(vo.getHot()));
        lotteryKindPO.setCreate_time(DispatcherUtils.parseDateTime(vo.getCreateTime()));
        lotteryKindPO.setUpdate_time(DispatcherUtils.parseDateTime(vo.getUpdateTime()));
        return lotteryKindPO;
    }

    public static List<LotteryKindVO> toVOList(List<LotteryKindPO> list){
        List<LotteryKindVO> result = new ArrayList<>();
        if(list != null && list.size() > 0){
            for (LotteryKindPO po : list) {
                result.add(toVO(po));
            }
        }
        return result;
    }

}
